home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / vidbasic.zip / VHORIZ.ASM < prev    next >
Assembly Source File  |  1990-11-29  |  7KB  |  186 lines

  1. ;«RM82»«TS8,16,24,32,40,48,56,64»
  2. ; Updated 11/20/90
  3.  
  4. ;============================================================================
  5. ;   Copyright (C) Copr. 1990 by Sidney J. Kelly
  6. ;           All Rights Reserved.
  7. ;           Sidney J. Kelly
  8. ;           150 Woodhaven Drive
  9. ;           Pittsburgh, PA 15228
  10. ;           home phone 412-561-0950 (7pm to 9:30pm EST)
  11. ;============================================================================
  12.  
  13. DOSSEG
  14. .MODEL MEDIUM, BASIC
  15. .data
  16.     EVEN
  17.     EXTRN   B$DVIDEOSEG:WORD
  18.     EXTRN   B$DVIDEOPORT:WORD
  19.     EXTRN   B$DVIDEOINSTL:BYTE
  20. .code
  21.  
  22. INCLUDE NOWAIT.INC
  23. EXTRN   Get_Adapter:FAR
  24.  
  25. msr_values      db 2ch,28h,2dh,29h    ; reprogram CGA values
  26.         db 2AH,2eh,1eh,29h      ; when turn CGA back on
  27.  
  28. ;=======================================================================
  29. ; DECLARE SUB RSCROLL (BYVAL Attribute%)
  30. ; CALL RSCROLL(Attribute%)
  31. ; Scrolls screen right
  32. ; Mostly for fun.  To be really useful would have to set it up for windows
  33. ; and would have to print using VPRINT.
  34. ; Designed to handle an 80 x 25 text display
  35. ;=======================================================================
  36.  
  37. EVEN
  38. RSCROLL Proc FAR BASIC USES DI SI, ATTRIB:Ptr
  39.     Push    DS        ; save it ourselves so we can control
  40.                 ; DGROUP addressibility
  41.     Pushf                   ; save state of direction flag
  42.                 ; QBASIC requires it to be cleared
  43.     Cmp     B$DVIDEOINSTL,1 ; See if we have done this before
  44.     JE      Didit           ; yep, so skip ahead
  45.     Call    Get_Adapter     ; call routine to find display type
  46.  
  47. Didit:
  48.     Mov     BX,B$DVIDEOSEG  ; restore the initialized values
  49.     Mov     ES,BX        ; set ES == Video Segment
  50.     Mov     DX,B$DVIDEOPORT ; puts 0 in DX if not snowy CGA
  51.     Mov     AX,ATTRIB       ; get the color ATTRIBUTE% that was passed
  52.                 ; (Variable must be passed by value)
  53.     Mov     AH,AL           ; put it into AH for screen writing below
  54.                 ; delay changing DS until finish reading stack
  55.     Mov     DS,BX           ; store start of video buffer in DS
  56.     Mov     CX,25           ; number of lines to clear
  57.     Or    DX,DX        ; is this a snowy CGA?
  58.     JZ    Not_CGA        ; if DX=0 then no
  59.  
  60. CGA_Off:
  61.     Mov    BX,AX        ; save AX in BX, following routine destroys AX
  62.     CLI                     ; prevent interrupts to speed routine
  63.     Wait_CGA_Retrace    ; wait for CGA retrace MACRO
  64.     Mov     DX,03D8h        ; load CGA mode control register
  65.     Mov     AL,00000001b    ; display = off if bit 3 = 0
  66.     Out     DX,AL
  67.     STI            ; turn interrupts back on
  68.     Mov    AX,BX        ; restore AX
  69.  
  70. Not_CGA:
  71.     Mov     DI,158          ; load offset of right hand column
  72.     Mov     AL,20h          ; load the space character
  73.  
  74. EVEN
  75. Fill_Space:
  76.     Stosw                   ; fill right hand column of display
  77.     Add     DI,158          ; skipping down each row (Stosw already 
  78.                 ; increments one character)
  79.     Loop    Fill_Space      ; loop for 25 rows
  80.  
  81.     Mov     CX,2000         ; number of words to move
  82.     Mov     SI,3998         ; start       DS:SI
  83.     Mov     DI,4000         ; destination ES:DI
  84.     Std                     ; set direction flag to count down
  85.     Rep     Movsw           ; move all bytes "up in memory" two bytes
  86.     Mov     DS:[00],AX      ; store a space at beginning
  87.     Popf                    ; restore direction flag
  88.     Pop    DS        ; restore addressibility of stack
  89.     Mov     DX,B$DVIDEOPORT ; load address of CGA retrace port
  90.     Or    DX,DX        ; Is it a snowy CGA?
  91.     JZ    Finis        ; nope
  92.  
  93. CGA_On:                ; else is snowy CGA
  94.     CLI            ; prevent interrupts to speed routine
  95.     Mov     DX,03D8h        ; load CRT Mode Control port addresss
  96.     Mov     AH,0Fh        ; get current video mode
  97.     Int     10h
  98.     LEA     BX,msr_values    ; Point BX to msr_values table
  99.     Xlat    msr_values    ; load table value depending on
  100.                 ; current CGA video mode in AL
  101.     Out     DX,AL        ; do it
  102.     STI            ; turn interrupts back on
  103.  
  104. Finis:
  105.     Ret                     ; remove one parameter (MASM does it)
  106. RSCROLL ENDP
  107.  
  108. ;=======================================================================
  109. ; DECLARE SUB LSCROLL (BYVAL Attribute%)
  110. ; CALL LSCROLL(Attribute%)
  111. ; Scrolls screen left
  112. ; Mostly for fun.  To be really useful would have to set it up for windows
  113. ; and would have to print using VPRINT.
  114. ; Designed to handle an 80 x 25 text display
  115. ;=======================================================================
  116.  
  117. EVEN
  118. LSCROLL Proc FAR BASIC USES DI SI, ATTRIB:Ptr
  119.     Push    DS        ; push it ourselves to control return
  120.                 ; of DGROUP addressibility
  121.     Cmp     B$DVIDEOINSTL,1 ; See if we have done this before
  122.     JE      Didit1          ; yep, so skip ahead
  123.     Call    Get_Adapter     ; call routine to find display type
  124.  
  125. Didit1:
  126.     Mov     BX,B$DVIDEOSEG  ; restore the initialized values
  127.     Mov     ES,BX
  128.     Mov     DX,B$DVIDEOPORT ; puts 0 in DX if not CGA
  129.     Mov     AX,ATTRIB       ; get the color ATTRIBUTE% that was passed
  130.     Mov     AH,AL           ; put it into AH for screen writing below
  131.                 ; delay changing DS until finish reading stack
  132.     Mov     DS,BX           ; store start of video buffer in DS
  133.     Mov     CX,25           ; number of lines to clear
  134.     Or    DX,DX        ; is this a snowy CGA?
  135.     JZ    Not_CGA1    ; if DX=0 then no snowy CGA
  136.  
  137. CGA_Off1:
  138.     Mov    BX,AX        ; save AX in BX following routine destroys AX
  139.     CLI                     ; prevent interrupts to speed routine
  140.     Wait_CGA_Retrace    ; wait for CGA retrace MACRO
  141.     Mov     DX,03D8h        ; load CGA mode control register
  142.     Mov     AL,00000001b    ; display = off if bit 3 = 0
  143.     Out     DX,AL
  144.     STI            ; turn interrupts back on
  145.     Mov    AX,BX        ; restore AX
  146.  
  147. Not_CGA1:
  148.     
  149.     Xor     DI,DI           ; load offset of left hand column
  150.     Mov     AL,20h          ; load the space character
  151.  
  152. EVEN
  153. Fill_Space1:
  154.     Stosw            ; fill left hand column of display
  155.     Add     DI,158        ; skipping down each row (Stosw already 
  156.                 ; increments one character)
  157.     Loop    Fill_Space1     ; loop for 25 rows
  158.  
  159.     Mov     CX,2000         ; number of words to move
  160.     Mov     SI,2            ; start       DS:SI
  161.     Mov     DI,0            ; destination ES:DI
  162.     Cld                     ; clear direction flag to count up
  163.     Rep     Movsw           ; move all bytes "backwards" two bytes
  164.     Mov     DS:[3998],AX    ; store a space at end of bottom row
  165.     Pop    DS        ; restore addressibility of DGROUP
  166.     Mov     DX,B$DVIDEOPORT ; get address of CGA retrace port
  167.     Or    DX,DX        ; Is it a snowy CGA?
  168.     JZ    Finis1         ; nope
  169.  
  170. CGA_On1:            ; else is snowy CGA
  171.     CLI            ; prevent interrupts to speed routine
  172.     Mov     DX,03D8h        ; load CRT Mode Control port addresss
  173.     Mov     AH,0Fh        ; get current video mode
  174.     Int     10h
  175.     LEA     BX,msr_values    ; Point BX to msr_values table
  176.     Xlat    msr_values    ; load table value depending on
  177.                 ; current CGA vid mode in AL
  178.     Out     DX,AL        ; do it
  179.     STI            ; turn interrupts back on
  180.  
  181. Finis1:
  182.  
  183.     Ret                     ; remove one parameter
  184. LSCROLL ENDP
  185. END
  186.